{extend name="public/base"/}
 {block name="content"}
  <section class="content">
            <div class="col-md-9" style="width:100%">
              <div class="box box-default">
			<div class="box-header">
				<h3 class="box-title">
				<a href="{:U('Links/index')}" class="btn btn-primary">链接列表</a>
				</h3>
				 <h3 class="box-title">
				<a href="{:U('Links/add')}" class="btn btn-primary">添加链接</a>
				</h3> 
				<h3 class="box-title">
				<a href="{:U('Links/lid_index')}" class="btn btn-primary">类别列表</a>
				</h3> 
				<h3 class="box-title">
				<a href="{:U('Links/lid_add')}" class="btn btn-primary">添加类别</a>
				</h3> 
				
			</div>
				<!-- /.box-header -->
                <!-- form start -->
                  <form action="{:U('Links/add')}" method="post">
                <div class="box-body">
                  <div class="row">
                    <div class="col-md-12">
                      <table class="table table-bordered">
					  	<tr>
                            <th width="140">类别:</th>
                        <td>						
							<select name="lid" class="form-control">
							<option value="0">请选择类别</option>
				            {volist name="linktype" id="data"}
							<option value="{$data.id}">{$data.name}</option>
							{/volist}
						     </select>
						</td>
                        </tr> 
						
                        <tr>
                            <th width="140">名称:</th>
                            <td><input class="form-control" type="text" name="name" value="" size="30"></td>
                        </tr>
						
						 <tr>
                            <th width="140">logo:</th>
                            <td>
                                <div id="logo" class="wu-example" name="logo">
                                    <!--用来存放文件信息-->
                                    <div id="thelist-logo" class="uploader-list">
                                        <?php if(!empty($value)){ ?>
                                        <div class="item">
                                            <input type="hidden" name="{$key}" value="{$value}" />
                                            <image style="width:100px;height:100px" src="{:change($value)}" />
                                        </div>
                                        <?php }; ?>
                                    </div>
                                    <div class="btns">
                                        <div class="picker" id="picker-logo">图片上传</div>
                                    </div>
                                </div>
                            </td>
                        </tr>
						<div id="yan"></div>
						 <tr>
                            <th width="140">链接:</th>
                            <td><input class="form-control" type="text" name="links" value="" size="30"></td>
                        </tr>
						

						  
					
                      </table>
                    </div><!-- /.col -->
                  </div><!-- /.row -->
                </div><!-- /.box-body -->
                <div class="box-footer">
                  <button type="submit" class="btn btn-primary">确认</button>
                </div>
				</form>
              
              </div><!-- /.box -->
            </div>

            <!-- test qiniu sdk -->
    
        <script type="application/javascript">

            function xmlhttp() {
                var $xmlhttp;

                if (window.XMLHttpRequest) {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    $xmlhttp = new XMLHttpRequest();
                } else {
                    // code for IE6, IE5
                    $xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                return $xmlhttp;
            }


            window.onload = function() {

                $xmlhttp = xmlhttp();
                $xmlhttp.onreadystatechange = function() {
                    if ($xmlhttp.readyState == 4) {
                        if($xmlhttp.status == 200){
                            document.getElementById('id_token').value = $xmlhttp.responseText;
                        } else {
                            alert('get uptoken other than 200 code was returned')
                        }
                    }
                }
               //向后端请求token
                //$upTokenUrl = '{:U('Qiniu/uptoken')}';
                $xmlhttp.open('GET', $upTokenUrl, true);
                $xmlhttp.send(); 


                $bucketDomain = 'http://7xvkxv.com1.z0.glb.clouddn.com';
                $file = document.getElementById('id_file');
                $file.onchange = function(){
                    $key = $file.value.split(/(\\|\/)/g).pop(); 
                    document.getElementById('id_key').value = $key;
                    
                    $url = document.getElementById('id_url')
                    $url.href = $url.text = $bucketDomain + '/' + $key;
                };
            }; 

        </script>



            <!-- test qiniu sdk -->

			</section>
 {/block}
